package scut.facerecognition.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import scut.facerecognition.entity.pojo.PostComment;

import java.util.List;

/**
 * 帖子评论 Mapper 接口
 */
@Mapper
public interface PostCommentMapper extends BaseMapper<PostComment> {
    
    /**
     * 获取帖子的一级评论列表
     * @param page 分页参数
     * @param postId 帖子ID
     * @return 评论分页列表
     */
    @Select("SELECT c.* FROM post_comment c WHERE c.post_id = #{postId} AND c.status = 1 ORDER BY c.add_time ")
    IPage<PostComment> selectRootComments(Page<PostComment> page, @Param("postId") Long postId);
    
    /**
     * 获取评论的子评论列表
     * @param parentId 父评论ID
     * @return 子评论列表
     */
    @Select("SELECT c.* FROM post_comment c WHERE c.parent_id = #{parentId} AND c.status = 1 ORDER BY c.add_time ASC")
    List<PostComment> selectChildComments(@Param("parentId") Long parentId);
}
